package com.example.onlineeducation.mapper

import com.example.onlineeducation.data.entity.UserProStudyTimeEntity
import com.example.onlineeducation.data.json.UserProStudyTimeJson
import com.example.onlineeducation.utils.YcTimeUtils
import com.yc.jetpacklib.extension.ycToNoEmpty
import com.yc.jetpacklib.extension.ycToNoEmptyHasUnit
import com.yc.jetpacklib.extension.ycToStringNoEmpty
import com.yc.jetpacklib.mapper.IMapper

class UserProStudyTimeMapper : IMapper<UserProStudyTimeJson?, UserProStudyTimeEntity> {
    override fun map(input: UserProStudyTimeJson?): UserProStudyTimeEntity {
        return if (input != null) {
            UserProStudyTimeEntity(
                YcTimeUtils.secondToString(input.dayTimes ?: 0),
                input.continuityDays.ycToNoEmptyHasUnit(unit = "天", "-"),
                YcTimeUtils.secondToString(input.totalTimes ?: 0),
                input.score.ycToNoEmpty()
            )
        } else {
            UserProStudyTimeEntity("-", "-", "-","-")
        }
    }
}

